#!/bin/bash find=$(find "/usr/local/bin" -name "gs-noX11") expectedval="/usr/local/bin/gs-noX11" if [ "$1" == "detect" ] then if [ "$find" == "$expectedval" ] then echo "GhostScript is installed" exit 0 else echo "GhostScript is not installed" exit 1 fi else if [ "$find" == "$expectedval" ] then echo "GhostScript is installed" else echo "GhostScript is not installed" fi if [ "$find" == "$expectedval" ] then echo "GhostScript exists and removing it" cd "/usr/local/" filesNeedToBeRemovedInBin="./bin/dvipdf ./bin/eps2eps ./bin/gs-X11 ./bin/gs-noX11 ./bin/gsbj ./bin/gsdj ./bin/gsdj500 ./bin/gslj ./bin/gslp ./bin/gsnd ./bin/lprsetup.sh ./bin/pdf2dsc ./bin/pdf2ps ./bin/pf2afm ./bin/pfbtopfa ./bin/pphs ./bin/printafm ./bin/ps2ascii ./bin/ps2epsi ./bin/ps2pdf ./bin/ps2pdf12 ./bin/ps2pdf13 ./bin/ps2pdf14 ./bin/ps2pdfwr ./bin/ps2ps ./bin/ps2ps2 ./bin/unix-lpr.sh" for file in $filesNeedToBeRemovedInBin do echo $file if [ -f "$file" ] then rm "$file" echo "Removed $file" fi done status=`echo $?` expectedVal="0" if [ $status -ne $expectedVal ] then exit 1 fi if [ -d "./share/ghostscript" ] then rm -rf "./share/ghostscript" fi status=`echo $?` expectedVal="0" if [ $status -ne $expectedVal ] then exit 1 fi filesNeedToBeRemovedInMan="./share/man/de/man1/dvipdf.1 ./share/man/de/man1/gsnd.1 ./share/man/de/man1/pdf2dsc.1 ./share/man/de/man1/pdf2ps.1 ./share/man/de/man1/printafm.1 ./share/man/de/man1/ps2ascii.1 ./share/man/de/man1/ps2pdf.1 ./share/man/de/man1/ps2ps.1 ./share/man/man1/dvipdf.1 ./share/man/man1/gs.1 ./share/man/man1/gslp.1 ./share/man/man1/gsnd.1 ./share/man/man1/pdf2dsc.1 ./share/man/man1/pdf2ps.1 ./share/man/man1/pf2afm.1 ./share/man/man1/pfbtopfa.1 ./share/man/man1/printafm.1 ./share/man/man1/ps2ascii.1 ./share/man/man1/ps2epsi.1 ./share/man/man1/ps2pdf.1 ./share/man/man1/ps2pdfwr.1 ./share/man/man1/ps2ps.1" for file in $filesNeedToBeRemovedInMan: do if [ -f "$file" ] then echo $file rm "$file" echo "Removed $file" fi done status=`echo $?` expectedVal="0" if [ $status -ne $expectedVal ] then exit 1 fi exit 0 fi fi